<template>
  <el-select v-model="id" size="small" 
    @change="selChange"
    placeholder="请选择审核类型"
    style="width: 100%">
    <el-option
      v-for="item in types"
      :key="item.key"
      :label="item.value"
      :value="item.key"
    />
  </el-select>
</template>

<script>
import { queryTypes } from '@/api/approval/approve'

export default {
  name: 'VerifyType',
  props: {
    value: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      id: null,
      types: []
    }
  },
  watch: {
    value: {
      handler(n, o) {
        this.id = n
      },
      immediate: false
    }
  },
  created() {
    this.queryTypes()
  },
  methods: {
    selChange() {
      this.$emit('input', this.id)
    },
    queryTypes() {
      queryTypes().then(res => {
        this.types = res.list
      }).catch(err => {
        this.$message.error(err.msg)
      })
    }
  }
}
</script>

<style scoped>
</style>
